<?php
$this->breadcrumbs=array(
	'Issues'=>array('index'),
	'Assign',
);

?>

<h1>Assign/Check editing questions/answer to editor</h1>
<div class="list-sort">
<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
  'htmlOptions'=>array('class'=>'form-horizontal'),
)); ?>
<?php echo CHtml::dropDownList('sort', '', $model->getListSort(),array('class'=>'sort'))?>
	<i class="icon-chevron-down"></i> 
	<input type="hidden" value="desc" name='sort_type'>
<?php $this->endWidget(); ?>
</div>
<?php
		$this->widget('zii.widgets.CListView', array(
		'id'=>'assign-issue-list',
		'dataProvider'=>$model->assign($ID),
		'pager'=>array
		(
			'firstPageLabel' => '&lt;&lt;',
	    'prevPageLabel'  => '&lt;',
	    'nextPageLabel'  => '&gt;',
	    'lastPageLabel'  => '&gt;&gt;',
			'header'=>'',
		),
		'emptyText'=>'Không có dữ liệu.',
		'itemView'=>'_view_assign_resolve',
	)); 
?>

<script type="text/javascript">
$(function() {
	$(".refresh").click(function() {
		console.log($(this));
		$(this).parent().children(".btn-success").removeAttr("disabled").removeClass("disabled");
		$(this).parent().children(".btn-inverse").removeAttr("disabled").removeClass("disabled");
	});
	$('.list-sort i').toggle(
			function() { 
				$('.list-sort i').attr('class','icon-chevron-up');
				$('.list-sort input:hidden').val('asc');
				$('.list-sort form').submit();
			}, 
			function() { 
				$('.list-sort i').attr('class','icon-chevron-down');
				$('.list-sort input:hidden').val('desc');
				$('.list-sort form').submit();
			}
		);
		$('.sort').change(function() {
			$('.list-sort form').submit();
		});
		$('.list-sort form').submit(function(){
			$.fn.yiiListView.update('assign-issue-list', {
				data: $(this).serialize()
			});
			return false;
		});
});


function beforeAssign(issueID,num,status) {
	var ediorID = $("#issue_"+issueID+"_"+num).val();
	$.ajax({
		url: baseUrl + "/admin/issue/setAssignResolve",
		data: {issueID: issueID, ediorID: ediorID, status: status, num: num},
		type: "POST",//or GET
		success: function(data) {
			if(data=="success") {
				alert(data);
				$("#"+status+"_"+issueID+"_"+num).addClass("disabled").attr("disabled","disabled");
			}
		}
	});
}
</script>